import React, {Component} from 'react';
import { WeaLocaleProvider } from 'ecCom';
import moment from 'moment';
const { getLabel } = WeaLocaleProvider;
const days = [
    () => getLabel(398, '星期日'),
    () => getLabel(392, '星期一'),
	() => getLabel(393, '星期二'),
	() => getLabel(394, '星期三'),
	() => getLabel(395, '星期四'),
	() => getLabel(396, '星期五'),
	() => getLabel(397, '星期六')
]

export default class Header extends Component{
    constructor(props){
        super(props);
        this.state = {
            date: null
        }
    }

    converDate = (dateStr) => {
        const d = (dateStr != null ? moment(dateStr, 'YYYY-MM-DD') : moment());
        return {
            dateStr: d.format('YYYY-MM-DD'),
            weekday: days[d.day()]()
        }
    }

    setDate = date => {
        this.setState({date});
    }

    render(){
        const {date} = this.state;
        const {dateStr, weekday} = this.converDate(date);
        return (
            <div className='header'>
                <span className='icon-coms-New-schedule icon' />
                <span>{dateStr}</span>
                <span>{weekday}</span>
            </div>
        )
    }
}